package fm.dongman.modellib.local;

import android.content.Context;

import org.jetbrains.annotations.NotNull;

import fm.dongman.animefm.contractlib.contract.FRankContract;
import fm.dongman.animefm.contractlib.model.FRankDataModel;

/**
 *
 * Created by Administrator on 2017/10/20.
 */

public class FRankLocalDataSource implements FRankContract.IFRankDataSource{
    private static FRankLocalDataSource SINGLETON;
    private Context mContext;
    private DataOperationHelper database;

    private FRankLocalDataSource(Context context){
        this.mContext=context;
        database=DataOperationHelper.getDataOperationHelper(context);
    }

    public static FRankLocalDataSource getInstance(Context context)
    {
        if(SINGLETON==null)
        {
            SINGLETON=new FRankLocalDataSource(context);
        }
        return SINGLETON;
    }

    @NotNull
    @Override
    public String getMoreRank() {
        return null;
    }

    @Override
    public void getData(@NotNull LoadSourceCallback<? super FRankDataModel> callback) {
        FRankDataModel dataModel = database.downFRank();
        callback.onDataLoaded(dataModel);
    }

    @Override
    public void saveData(FRankDataModel dataModel) {
        database.saveFRank(dataModel);
    }

    @Override
    public void refreshData() {

    }

    @Override
    public void offLine() {

    }
}
